<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 6.3.0">

  <link rel="apple-touch-icon" sizes="180x180" href="/bestfyw/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/bestfyw/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/bestfyw/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/bestfyw/images/logo.svg" color="#222">

<link rel="stylesheet" href="/bestfyw/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css" integrity="sha256-/4UQcSmErDzPCMAiuOiWPVVsNN2s3ZY/NsmXNcj0IFc=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">

<script class="next-config" data-name="main" type="application/json">{"hostname":"feng-yaowen.gitee.io","root":"/bestfyw/","images":"/bestfyw/images","scheme":"Gemini","darkmode":false,"version":"8.15.0","exturl":false,"sidebar":{"position":"right","display":"post","padding":18,"offset":12},"copycode":{"enable":false,"style":null},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":true,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":false,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/bestfyw/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false}}</script><script src="/bestfyw/js/config.js"></script>

    <meta name="description" content="无法使用root账户ssh到服务器的原因某些操作系统（如ubuntu）限制了用户直接使用root账户直接登录，所以用户在用到类似的系统或者有相关设置的系统，是不能直接用root账户ssh连接到服务器的。 解决办法修改ssh的设置，打开允许以root账户登录的设置。">
<meta property="og:type" content="blog">
<meta property="og:title" content="解决无法使用root账号ssh到服务器的问题">
<meta property="og:url" content="http://feng-yaowen.gitee.io/bestfyw/2023/04/01/%E8%A7%A3%E5%86%B3%E6%97%A0%E6%B3%95%E4%BD%BF%E7%94%A8root%E8%B4%A6%E6%88%B7ssh%E5%88%B0%E6%9C%8D%E5%8A%A1%E5%99%A8/index.html">
<meta property="og:site_name" content="冯耀文天天向上">
<meta property="og:description" content="无法使用root账户ssh到服务器的原因某些操作系统（如ubuntu）限制了用户直接使用root账户直接登录，所以用户在用到类似的系统或者有相关设置的系统，是不能直接用root账户ssh连接到服务器的。 解决办法修改ssh的设置，打开允许以root账户登录的设置。">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2023-04-01T03:03:27.000Z">
<meta property="article:modified_time" content="2023-04-11T13:37:09.484Z">
<meta property="article:author" content="FengYaoWen">
<meta property="article:tag" content="Linux">
<meta name="twitter:card" content="summary">


<link rel="canonical" href="http://feng-yaowen.gitee.io/bestfyw/2023/04/01/%E8%A7%A3%E5%86%B3%E6%97%A0%E6%B3%95%E4%BD%BF%E7%94%A8root%E8%B4%A6%E6%88%B7ssh%E5%88%B0%E6%9C%8D%E5%8A%A1%E5%99%A8/">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"http://feng-yaowen.gitee.io/bestfyw/2023/04/01/%E8%A7%A3%E5%86%B3%E6%97%A0%E6%B3%95%E4%BD%BF%E7%94%A8root%E8%B4%A6%E6%88%B7ssh%E5%88%B0%E6%9C%8D%E5%8A%A1%E5%99%A8/","path":"2023/04/01/解决无法使用root账户ssh到服务器/","title":"解决无法使用root账号ssh到服务器的问题"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>解决无法使用root账号ssh到服务器的问题 | 冯耀文天天向上</title>
  








  <noscript>
    <link rel="stylesheet" href="/bestfyw/css/noscript.css">
  </noscript>
</head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <div class="column">
      <header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/bestfyw/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">冯耀文天天向上</p>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">FengYaoWen's Personal Space</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger" aria-label="搜索" role="button">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/bestfyw/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a></li><li class="menu-item menu-item-tags"><a href="/bestfyw/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签<span class="badge">6</span></a></li><li class="menu-item menu-item-categories"><a href="/bestfyw/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类<span class="badge">3</span></a></li><li class="menu-item menu-item-archives"><a href="/bestfyw/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档<span class="badge">5</span></a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup"><div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" maxlength="80"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close" role="button">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="search-result-container no-result">
  <div class="search-result-icon">
    <i class="fa fa-spinner fa-pulse fa-5x"></i>
  </div>
</div>

    </div>
  </div>

</header>
        
  
  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E6%97%A0%E6%B3%95%E4%BD%BF%E7%94%A8root%E8%B4%A6%E6%88%B7ssh%E5%88%B0%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%9A%84%E5%8E%9F%E5%9B%A0"><span class="nav-number">1.</span> <span class="nav-text">无法使用root账户ssh到服务器的原因</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E8%A7%A3%E5%86%B3%E5%8A%9E%E6%B3%95"><span class="nav-number">2.</span> <span class="nav-text">解决办法</span></a></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="FengYaoWen"
      src="https://i.328888.xyz/2023/03/30/iCvs9C.jpeg">
  <p class="site-author-name" itemprop="name">FengYaoWen</p>
  <div class="site-description" itemprop="description">终身学习，任务导向。持之以恒，严格自律。修身养性，正直谦卑。</div>
</div>
<div class="site-state-wrap animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/bestfyw/archives/">
          <span class="site-state-item-count">5</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/bestfyw/categories/">
        <span class="site-state-item-count">3</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
          <a href="/bestfyw/tags/">
        <span class="site-state-item-count">6</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author animated">
      <span class="links-of-author-item">
        <a href="https://github.com/f1ywin" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;f1ywin" rel="noopener me" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:fyw1fyw@163.com" title="E-Mail → mailto:fyw1fyw@163.com" rel="noopener me" target="_blank"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
  </div>

        </div>
      </div>
    </div>

    
  </aside>


    </div>

    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://feng-yaowen.gitee.io/bestfyw/2023/04/01/%E8%A7%A3%E5%86%B3%E6%97%A0%E6%B3%95%E4%BD%BF%E7%94%A8root%E8%B4%A6%E6%88%B7ssh%E5%88%B0%E6%9C%8D%E5%8A%A1%E5%99%A8/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="https://i.328888.xyz/2023/03/30/iCvs9C.jpeg">
      <meta itemprop="name" content="FengYaoWen">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="冯耀文天天向上">
      <meta itemprop="description" content="终身学习，任务导向。持之以恒，严格自律。修身养性，正直谦卑。">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="解决无法使用root账号ssh到服务器的问题 | 冯耀文天天向上">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          解决无法使用root账号ssh到服务器的问题
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2023-04-01 11:03:27" itemprop="dateCreated datePublished" datetime="2023-04-01T11:03:27+08:00">2023-04-01</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar-check"></i>
      </span>
      <span class="post-meta-item-text">更新于</span>
      <time title="修改时间：2023-04-11 21:37:09" itemprop="dateModified" datetime="2023-04-11T21:37:09+08:00">2023-04-11</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/bestfyw/categories/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F/" itemprop="url" rel="index"><span itemprop="name">操作系统</span></a>
        </span>
    </span>

  
    <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv">
      <span class="post-meta-item-icon">
        <i class="far fa-eye"></i>
      </span>
      <span class="post-meta-item-text">阅读次数：</span>
      <span id="busuanzi_value_page_pv"></span>
    </span>
    <span class="post-meta-break"></span>
    <span class="post-meta-item" title="本文字数">
      <span class="post-meta-item-icon">
        <i class="far fa-file-word"></i>
      </span>
      <span class="post-meta-item-text">本文字数：</span>
      <span>198</span>
    </span>
    <span class="post-meta-item" title="阅读时长">
      <span class="post-meta-item-icon">
        <i class="far fa-clock"></i>
      </span>
      <span class="post-meta-item-text">阅读时长 &asymp;</span>
      <span>1 分钟</span>
    </span>
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
        <h1 id="无法使用root账户ssh到服务器的原因"><a href="#无法使用root账户ssh到服务器的原因" class="headerlink" title="无法使用root账户ssh到服务器的原因"></a>无法使用root账户ssh到服务器的原因</h1><p>某些操作系统（如ubuntu）限制了用户直接使用root账户直接登录，所以用户在用到类似的系统或者有相关设置的系统，是不能直接用root账户ssh连接到服务器的。</p>
<h1 id="解决办法"><a href="#解决办法" class="headerlink" title="解决办法"></a>解决办法</h1><p>修改ssh的设置，打开允许以root账户登录的设置。</p>
<span id="more"></span>

<ol>
<li>编辑该文件</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">vim /etc/ssh/sshd_config</span><br></pre></td></tr></table></figure>

<ol start="2">
<li>找到PermitRootLogin Prohibit-password选项，取消掉注释，然后修改为</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">PermitRootLogin <span class="built_in">yes</span></span><br></pre></td></tr></table></figure>

<ol start="3">
<li>重启ssh服务</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">/etc/init.d/ssh restart</span><br></pre></td></tr></table></figure>

<p>完成后，即可以root账号登录</p>
<p>未设置root密码或者忘记密码的，可以执行以下进行密码修改</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo passwd root</span><br></pre></td></tr></table></figure>

<p>输入新密码和重复新密码即可</p>

    </div>

    
    
    

    <footer class="post-footer">
          

<div class="post-copyright">
<ul>
  <li class="post-copyright-author">
      <strong>本文作者： </strong>FengYaoWen
  </li>
  <li class="post-copyright-link">
      <strong>本文链接：</strong>
      <a href="http://feng-yaowen.gitee.io/bestfyw/2023/04/01/%E8%A7%A3%E5%86%B3%E6%97%A0%E6%B3%95%E4%BD%BF%E7%94%A8root%E8%B4%A6%E6%88%B7ssh%E5%88%B0%E6%9C%8D%E5%8A%A1%E5%99%A8/" title="解决无法使用root账号ssh到服务器的问题">http://feng-yaowen.gitee.io/bestfyw/2023/04/01/解决无法使用root账户ssh到服务器/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" rel="noopener" target="_blank"><i class="fab fa-fw fa-creative-commons"></i>BY-NC-SA</a> 许可协议。转载请注明出处！
  </li>
</ul>
</div>

          <div class="post-tags">
              <a href="/bestfyw/tags/Linux/" rel="tag"># Linux</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/bestfyw/2023/03/31/2023%E5%AD%A6%E4%B9%A0%E4%B9%A6%E7%B1%8D%E4%B9%A6%E5%8D%95/" rel="prev" title="2023学习书籍书单">
                  <i class="fa fa-chevron-left"></i> 2023学习书籍书单
                </a>
            </div>
            <div class="post-nav-item">
            </div>
          </div>
    </footer>
  </article>
</div>






    <div class="comments utterances-container"></div>
</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">


<div class="copyright">
  &copy; 
  <span itemprop="copyrightYear">2023</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">FengYaoWen</span>
</div>
<div class="wordcount">
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-line"></i>
    </span>
      <span>站点总字数：</span>
    <span title="站点总字数">1k</span>
  </span>
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
      <span>站点阅读时长 &asymp;</span>
    <span title="站点阅读时长">4 分钟</span>
  </span>
</div>
<div class="busuanzi-count">
    <span class="post-meta-item" id="busuanzi_container_site_uv">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-item" id="busuanzi_container_site_pv">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>

    </div>
  </footer>

  
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up fa-lg"></i>
    <span>0%</span>
  </div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
<script src="/bestfyw/js/comments.js"></script><script src="/bestfyw/js/utils.js"></script><script src="/bestfyw/js/motion.js"></script><script src="/bestfyw/js/next-boot.js"></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-generator-searchdb/1.4.1/search.js" integrity="sha256-1kfA5uHPf65M5cphT2dvymhkuyHPQp5A53EGZOnOLmc=" crossorigin="anonymous"></script>
<script src="/bestfyw/js/third-party/search/local-search.js"></script>





  
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>




<script class="next-config" data-name="utterances" type="application/json">{"enable":true,"repo":"f1ywin/bestfyw.github.io","issue_term":"https://f1ywin.github.io/bestfyw.github.io","theme":"github-light"}</script>
<script src="/bestfyw/js/third-party/comments/utterances.js"></script>

</body>
</html>
